#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 15;
const int MOD = 10000007;

int n, m;
ll a[N][N], c[N][N];
ll b[N];
void matmul(ll a[N][N], ll b[N][N], ll c[N][N]) {
  ll t[N][N] = {0};
  rep(i, 0, n) rep(j, 0, n) rep(k, 0, n) {
    t[i][j] = (t[i][j] + a[i][k] * b[k][j] % MOD) % MOD;
  }
  rep(i, 0, n) rep(j, 0, n) c[i][j] = t[i][j];
}
void matmul(ll a[N][N], ll b[N], ll c[N]) {
  ll t[N] = {0};
  rep(i, 0, n) rep(j, 0, n) { t[i] = (t[i] + a[i][j] * b[j] % MOD) % MOD; }
  rep(i, 0, n) c[i] = t[i];
}
void matpow(ll b[N][N], ll p, ll c[N][N]) {
  ll bb[N][N];
  ll t[N][N] = {0};
  rep(i, 0, n) t[i][i] = 1;
  rep(i, 0, n) rep(j, 0, n) bb[i][j] = b[i][j];
  while (p) {
    if (p & 1) matmul(t, bb, t);
    matmul(bb, bb, bb);
    p >>= 1;
  }
  rep(i, 0, n) rep(j, 0, n) c[i][j] = t[i][j];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (cin >> n >> m) {
    memset(a, 0, sizeof(a));
    a[0][0] = 10, a[0][n + 1] = 1;
    rep(i, 1, n) rep(j, 0, i) a[i][j] = 1;
    a[n + 1][n + 1] = 1;
    memset(b, 0, sizeof(b));
    b[0] = 233;
    rep(i, 1, n) cin >> b[i];
    b[n + 1] = 3;
    n++;
    matpow(a, m, c);
    matmul(c, b, b);
    cout << b[n - 1] << endl;
  }

  return 0;
}